package com.simple.datax.conn.impl;

import com.alibaba.dubbo.common.logger.Logger;
import com.alibaba.dubbo.common.logger.LoggerFactory;

/** 
 * @Title: SendThread.java 
 * @Package com.simple.datax.conn.impl 
 * @Description: 可池化线程对象，封装Thread对象。
 * @author Joe Jin 
 * @date 2013-1-10
 * @version V1.0 
 */
public class SendThread {
	private static final Logger logger = LoggerFactory
			.getLogger(SendThread.class);
	private SendThreadPool pool = null;
	
	// 当前线程索引
//	private int index;
	
	/**
	 * 构造器
	 * @param pool 池对象
	 */
	public SendThread(SendThreadPool pool) {
		this.pool = pool;
	}
	
	/**
	 * 构造器
	 * @param pool 池对象
	 * @param index 对象索引
	 */
	public SendThread(SendThreadPool pool, int index) {
		this.pool = pool;
//		this.index = index;
	}
	
	// 启动执行线程
	public Thread execute(Runnable r) {
		Thread thread = new Worker(r, pool);
		thread.start();
		logger.debug("sending thread started.");
		return thread;
	}

}
